package com.shrct.businessprocess.organization.impl;

import com.shrct.businessprocess.organization.RCEnterprise;
import com.shrct.businessprocess.organization.RCEnterpriseLocation;
import com.shrct.businessprocess.organization.impl.RCEnterpriseImpl;
import com.shrct.businessprocess.organization.proxy.RCEnterpriseLocationProxy;
import edu.fudan.mylang.pf.BaseModelObject;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.hibernate.annotations.DiscriminatorOptions;

@Entity
@DiscriminatorValue("RCENTERPRISELOCATION_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "rcenterpriselocation")
public class RCEnterpriseLocationImpl extends BaseModelObject implements RCEnterpriseLocation {
  public RCEnterpriseLocationImpl() {
    super();
  }
  
  public RCEnterpriseLocationImpl(final RCEnterprise enterprise) {
    super();
    this.enterprise = enterprise;
  }
  
  @JoinColumn(name = "enterprise_id")
  @ManyToOne(targetEntity = RCEnterpriseImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCEnterprise enterprise;
  
  public RCEnterprise getEnterprise() {
    return this.enterprise;
  }
  
  public RCEnterpriseLocation setEnterprise(final RCEnterprise enterprise) {
    this.enterprise = enterprise;
    return this;			
    
  }
  
  private String location;
  
  public String getLocation() {
    return this.location;
  }
  
  public RCEnterpriseLocation setLocation(final String location) {
    this.location = location;
    return this;			
    
  }
  
  public static RCEnterpriseLocation create(final RCEnterprise enterprise, final IObjectFactory objectFactory) {
    com.shrct.businessprocess.organization.RCEnterpriseLocation rCEnterpriseLocation = new com.shrct.businessprocess.organization.impl.RCEnterpriseLocationImpl(
    	enterprise
    );
    objectFactory.create(rCEnterpriseLocation);
    return rCEnterpriseLocation;			
    
  }
  
  public static RCEnterpriseLocation createRCEnterpriseLocationImpl(final RCEnterprise enterprise, final IObjectFactory objectFactory, final Procedure1<RCEnterpriseLocation> init) {
    com.shrct.businessprocess.organization.RCEnterpriseLocation rCEnterpriseLocation = new com.shrct.businessprocess.organization.impl.RCEnterpriseLocationImpl(
    	enterprise
    );
    objectFactory.create(rCEnterpriseLocation);
    init.apply(rCEnterpriseLocation);
    
    return rCEnterpriseLocation;			
    
  }
  
  public RCEnterpriseLocationProxy toProxy() {
    com.shrct.businessprocess.organization.proxy.RCEnterpriseLocationProxy proxy = new com.shrct.businessprocess.organization.proxy.RCEnterpriseLocationProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
